package com.andengine.editor.textureregioneditor;

import java.awt.Component;
import javax.swing.DefaultListCellRenderer;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;

/**
 * @author sad
 */
public class TexturesListCellRenderer extends DefaultListCellRenderer {

    @Override
    public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        
        if(value!=null){
            label.setIcon(new ImageIcon(((TextureFileWithThumbnail)value).getThumbnail()));
        }else{
        label.setIcon(null);
        }
        return label;
    }
}
